ineq(x)/ineq(y)
mean(y)
n = exp(seq(log(100), log(10^6), length.out = 1000))
n = round(n)
n
x = rlnorm(n[i], 10, 1)
x = rlnorm(n[i], 10, 1)
i = 10
x = rlnorm(n[i], 10, 1)
max(x)/mean(x)
for (i in 1:l){
x = rlnorm(n[i], 10, 1)
CEO.ratio[i] = max(x)/mean(x)
}
source('~/Desktop/Lognorm Firm CEO.R')
source('~/Desktop/Lognorm Firm CEO.R')
CEO.ratio = rep(NA, l)
source('~/Desktop/Lognorm Firm CEO.R')
plot(n, CEO.ratio)
plot(n, CEO.ratio, log="xy")
source('~/Desktop/Lognorm Firm CEO.R')
source('~/Desktop/Lognorm Firm CEO.R')
source('~/Desktop/Lognorm Firm CEO.R')
source('~/Desktop/Lognorm Firm CEO.R')
source('~/Desktop/Lognorm Firm CEO.R')
source('~/Desktop/Lognorm Firm CEO.R')
n = rlnorm(10^5, 20, 4)
hist(log(n))
hist(log10(n))
n = rlnorm(10^5, 15, 4)
hist(log10(n))
n = rlnorm(10^5, 11, 4)
hist(log10(n))
n = rlnorm(10^5, 11, 2)
hist(log10(n))
summary(n)
n = rlnorm(10^5, 11, 1.5)
hist(log10(n))
summary(n)
n = rlnorm(10^5, 11, 1)
summary(n)
n = rlnorm(10^5, 10, 1)
summary(n)
source('~/Desktop/Lognorm Firm CEO.R')
r = lm(log(CEO.ratio) ~ log(n))
summary(r)$r.squared
source('~/Desktop/Lognorm Firm CEO.R')
summary(r)$r.squared
source('~/Desktop/Lognorm Firm CEO.R')
summary(r)$r.squared
source('~/Desktop/Lognorm Firm CEO.R')
source('~/Desktop/Lognorm Firm CEO.R')
x = rlnorm(10^5, 10, 1.5)
library(ineq)
x = rlnorm(10^5, 10, 1.5)
ineq(x)
source('~/Desktop/Lognorm Firm CEO.R')
x = rlnorm(10^5, 10, 1.1)
ineq(x)
source('~/Desktop/Lognorm Firm CEO.R')
x = rlnorm(10^5, 10, 0.8)
ineq(x)
x = rlnorm(10^5, 10, 0.5)
ineq(x)
source('~/Desktop/Lognorm Firm CEO.R')
exp = 1:10
b = 10^5
exp = 0:10
b = 10^5
l = b*(0.5)^exp
l = floor(l)
sum(l)
l
exp = 0:20
b = 10^5
l = b*(0.5)^exp
l = floor(l)
l
p = 1.1^exp
p
pay = cumprod(p)
pay
mu = log(pay)
sigma = 0.2
firm = data.frame(l,pay)
View(firm)
firm = firm[firm$l != 0 ]
firm = firm[firm$l != 0 ,]
View(firm)
l = length(firm[,1])
source('~/Desktop/CEO TEst.R')
library(ineq)
hist(payroll)
hist(log(payroll))
hist(log(payroll), breaks  = 100)
ineq(payroll)
max(payroll)/mean(payroll)
View(firm)
p = 1.02^exp
pay = cumprod(p)
firm = data.frame(l,pay)
View(firm)
source('~/Desktop/CEO TEst.R')
max(payroll)/mean(payroll)
ineq(payroll)
source('~/Desktop/CEO TEst.R')
g = ineq(payroll)
CEO = max(payroll)/mean(payroll)
source('~/Desktop/CEO TEst.R')
View(firm)
s = 1.1^exp
l = b*(s)^exp
l = floor(l)
p = 1.05^exp
pay = cumprod(p)
mu = log(pay)
sigma = 0.2
View(firm)
l = b*(1/s)^exp
l = floor(l)
p = 1.05^exp
pay = cumprod(p)
mu = log(pay)
sigma = 0.2
firm = data.frame(l,pay)
source('~/Desktop/CEO TEst.R')
View(firm)
plot(l)
exp = 0:20
b = 10^5
s = 1.1^exp
l = b*(1/s)^exp
l = floor(l)
plot(l)
g = ineq(payroll)
CEO = max(payroll)/mean(payroll)
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
plot(l)
View(firm)
plot(firm$l)
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
plot(pay)
plot(log(pay)
plot(log(pay))
plot(log(pay))
View(firm)
library(ineq)
x = c(31321, 1611)
ineq(x)
between = c(31321, 1611)
ineq(between)
gini.between = ineq(between)
gini.within = mean(c(0.64,0.48))
gini.between/gini.within
between = c(38328, 3571)
gini.between = ineq(between)
gini.within = mean(c(0.64,0.48))
gini.between/gini.within
x = rlnorm(10^6, 10, 2)
p = 10^6*0.01
x = sort(x)
y = head(x, p)
hist(y)
y = x[p, 2*p]
y = x[p:2*p]
y = x[p:(2*p)]
hist(y)
library(ineq)
ineq(y)
y = x[(3p):(4*p)]
y = x[(3*p):(4*p)]
ineq(y)
hist(y)
ineq(y)
y = x[(99*p):(100*p)]
ineq(y)
hist(y)
ineq(y)
y = x[(80*p):(81*p)]
ineq(y)
hist(y)
hist(log(y))
y = x[(95*p):(95*p)]
ineq(y)
y = x[(95*p):(96*p)]
ineq(y)
hist(log(y))
y = x[(98*p):(99*p)]
ineq(y)
hist(log(y))
y = x[(99*p):(100*p)]
ineq(x)
x = rlnorm(10^6, 10, 1)
x = sort(x)
ineq(x)
p = 10^6*0.01
y = x[(99*p):(100*p)]
ineq(y)
hist(log(y))
y = x[(98*p):(99*p)]
ineq(y)
hist(log(y))
y = tail(x, p)
ineq(y)
hist(log(y))
hist(log(y), breaks = 100)
mean(y)
sd(y)/mean(y)
y = x[(98*p):(99*p)]
mean(y)
sd(y)/mean(y)
hist(y, breaks = 100)
y = x[(90*p):(91*p)]
ineq(y)
mean(y)
sd(y)/mean(y)
hist(y, breaks = 100)
ineq(y)
ineq(y)
y = x[(70*p):(71*p)]
ineq(y)
mean(y)
sd(y)/mean(y)
hist(y, breaks = 100)
x, breaks = 100)
hist(100), breaks = 100)
hist(x, breaks = 100)
hist(x, breaks = 100, xlim = c(0, 10^5))
hist(x, breaks = 1000, xlim = c(0, 10^5))
p = quantile(x, probs = seq(0,1, length.out = 100))
p
p = data.frame(quantile(x, probs = seq(0,1, length.out = 100)))
View(p)
p = data.frame(quantile(x, probs = seq(0,1, 0.01)))
View(p)
ineq(x)
p = quantile(x, probs = seq(0,1, 0.01))
test = ineq(p)
test = ineq(p[1:99])
ineq(p[1:99])
ineq(x)
x = rlnorm(10^6, 10, 1)
x = sort(x)
ineq(x)
p = quantile(x, probs = seq(0,1, 0.01))
ineq(p[1:99])
p
p = quantile(x, probs = seq(0,1, 0.1))
ineq(p[1:99])
ineq(p[1:10])
p
install.packages("XML")
install.packages("XML")
library(XML)
test = xmlToList("Test.xml")
test = xmlToList("Test.XML")
1+NA
x = NA
y = 10
x+y
library(ineq)
x = rlnorm(10^5, 10, 0.8)
ineq(x)
plnorm(10, 10, 0.8)
qlnorm(10, 10, 0.8)
?lnorm
?qlnorm
plnorm(10, 10, 0.8)
qlnorm(0.1, 10, 0.8)
qlnorm(0.9, 10, 0.8)
qlnorm(0.25, 10, 0.8)
mu = log(36)
sd = sqrt(2*(log(48) - mu))
sigma = sqrt(2*(log(48) - mu))
library(NORMT3)
erf(sigma/2)
erf(sigma/2)
year = 1994:2015
l = length(year)
url = "http://www.census.gov/data/tables/time-series/demo/income-poverty/cps-pinc/pinc-06.2015.html"
final = NULL
t = year[i]
i = 1
t = year[i]
t.sub = as.character(t)
url.year = gsub("2015", t, url)
doc = htmlParse(url.year)
library(readr)
library(XML)
doc = htmlParse(url.year)
links <- xpathSApply(doc, "//a/@href")
links
install.packages("jpeg")
install.packages("tcltk2")
install.packages("jpeg")
library(tcltk2)
library(jpeg)
library(zoo)
setwd("~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund")
jpegfile<-tk_choose.files(caption="Grund_1.jpg")
jpegfile<-tk_choose.files(caption="JPEG FILE")
(outfile<-paste(unlist(strsplit(jpegfile,"\\."))[1],".txt",sep=""))
ReadAndCal = function(fname)
{
ReadImg(fname)
calpoints <- locator(n=4,type='p',pch=4,col='blue',lwd=2)
return(calpoints)
}
ReadImg = function(fname)
{
img <- readJPEG(fname)
op <- par(mar=c(0,0,0,0))
on.exit(par(op))
plot.new()
rasterImage(img,0,0,1,1)
}
DigitData = function(col='red',type='p',...)
{
type <- ifelse(type=='b','o',type)
type <- ifelse(type%in%c('l','o','p'),type,'p')
locator(type=type,col=col,...)
}
Calibrate = function(data,calpoints,x1,x2,y1,y2)
{
x 		<- calpoints$x[c(1,2)]
y 		<- calpoints$y[c(3,4)]
cx <- lm(formula = c(x1,x2) ~ c(x))$coeff
cy <- lm(formula = c(y1,y2) ~ c(y))$coeff
data$x <- data$x*cx[2]+cx[1]
data$y <- data$y*cy[2]+cy[1]
Calibrate = function(data,calpoints,x1,x2,y1,y2)
{
x 		<- calpoints$x[c(1,2)]
y 		<- calpoints$y[c(3,4)]
cx <- lm(formula = c(x1,x2) ~ c(x))$coeff
cy <- lm(formula = c(y1,y2) ~ c(y))$coeff
data$x <- data$x*cx[2]+cx[1]
data$y <- data$y*cy[2]+cy[1]
return(as.data.frame(data))
}
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund/Digitize.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund/Digitize.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund/Digitize.R')
library(tcltk2)
library(jpeg)
library(zoo)
#load imagefile
jpegfile<-tk_choose.files(caption="JPEG FILE")
(outfile<-paste(unlist(strsplit(jpegfile,"\\."))[1],".txt",sep=""))
#digitize functions
ReadAndCal = function(fname)
{
ReadImg(fname)
calpoints <- locator(n=4,type='p',pch=4,col='blue',lwd=2)
return(calpoints)
}
ReadImg = function(fname)
{
img <- readJPEG(fname)
op <- par(mar=c(0,0,0,0))
on.exit(par(op))
plot.new()
rasterImage(img,0,0,1,1)
}
DigitData = function(col='red',type='p',...)
{
type <- ifelse(type=='b','o',type)
type <- ifelse(type%in%c('l','o','p'),type,'p')
locator(type=type,col=col,...)
}
Calibrate = function(data,calpoints,x1,x2,y1,y2)
{
x 		<- calpoints$x[c(1,2)]
y 		<- calpoints$y[c(3,4)]
cx <- lm(formula = c(x1,x2) ~ c(x))$coeff
cy <- lm(formula = c(y1,y2) ~ c(y))$coeff
data$x <- data$x*cx[2]+cx[1]
data$y <- data$y*cy[2]+cy[1]
return(as.data.frame(data))
}
(cal = ReadAndCal(jpegfile))
# https://www.r-bloggers.com/digitizing-jpeg-graphs-in-r/
library(tcltk2)
library(jpeg)
library(zoo)
#load imagefile
jpegfile<-tk_choose.files(caption="JPEG FILE")
(outfile<-paste(unlist(strsplit(jpegfile,"\\."))[1],".txt",sep=""))
#digitize functions
ReadAndCal = function(fname)
{
ReadImg(fname)
calpoints <- locator(n=4,type='p',pch=4,col='blue',lwd=2)
return(calpoints)
}
ReadImg = function(fname)
{
img <- readJPEG(fname)
op <- par(mar=c(0,0,0,0))
on.exit(par(op))
plot.new()
rasterImage(img,0,0,1,1)
}
DigitData = function(col='red',type='p',...)
{
type <- ifelse(type=='b','o',type)
type <- ifelse(type%in%c('l','o','p'),type,'p')
locator(type=type,col=col,...)
}
Calibrate = function(data,calpoints,x1,x2,y1,y2)
{
x 		<- calpoints$x[c(1,2)]
y 		<- calpoints$y[c(3,4)]
cx <- lm(formula = c(x1,x2) ~ c(x))$coeff
cy <- lm(formula = c(y1,y2) ~ c(y))$coeff
data$x <- data$x*cx[2]+cx[1]
data$y <- data$y*cy[2]+cy[1]
return(as.data.frame(data))
}
(cal = ReadAndCal(jpegfile))
(data.points = DigitData(col = 'red'))
setwd("~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund")
setwd("~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund")
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund/Parametric Fit.R')
write_csv(output, "Grund Level Results.csv")
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund/Parametric Fit.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund/Parametric Fit.R')
gini
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Data/Formatting.R')
dir = dirname(rstudioapi::getActiveDocumentContext()$path)
workspace = paste(dir, "/Data", sep = "")
setwd(workspace)
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Data/Formatting.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Data/Formatting.R')
dir = dirname(rstudioapi::getActiveDocumentContext()$path)
dir
dir = dirname(rstudioapi::getActiveDocumentContext()$path)
workspace = gsub("Data", "Functions", dir)
setwd(workspace)
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Data/Formatting.R')
O = read_csv("Grund Merge.csv")
library(actuar)
library(ineq)
library(readr)
library(doSNOW)
library(foreach)
library(snow)
library(tcltk)
library(data.table)
O = read_csv("Grund Merge.csv")
quants <- c(0.5, 0.01, 0.99)
qlnorm(quants, 1,1)
i = 1
q = as.numeric(O[i , 4:5]/1000)
View(O)
print("Burr")
# code from Andrie de Vries
# https://www.r-bloggers.com/parameters-and-percentiles-the-gamma-distribution/
library(actuar)
library(ineq)
library(readr)
library(doSNOW)
library(foreach)
library(snow)
library(tcltk)
library(data.table)
# Clusters
##################################################
cl <- makeCluster(4, type="SOCK")
registerDoSNOW(cl)
clusterSetupRNG (cl, type = "RNGstream")
O = read_csv("Grund Merge.csv")
error <- function(p=c(10, 3), quantiles, exp){
gx <- qburr(p=quantiles, shape1 = p[1], shape2 = p[2], scale = p[3])
sum(abs((gx-exp)))
}
quants <- c(0.05, 0.95)
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/burr.R')
stopCluster(cl)
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/burr.R')
View(fit)
View(fit)
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/FUNCTION MASTER SCRIPT.R')
stopCluster(cl)
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/dagum fit.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/FUNCTION MASTER SCRIPT.R')
